package entity.result;

import enums.http.ResponseCodeEnum;

/**
 * 返回普通数据
 *
 * @author zhanyh
 * @date 2018年10月16日
 */
public class EntityResult<T> extends BaseResult {
	/**
	 *
	 */
	private static final long serialVersionUID = -5947456789732446136L;
	protected T data;

	public T getData() {
		return data;
	}

	public void setData(T data) {
		this.data = data;
	}

	public EntityResult() {
	}

	public EntityResult(T t) {
		this.setSuccess(true);
		this.setCode(ResponseCodeEnum.SUCCESS.getCode());
		this.setData(t);
	}

	/**
	 * 响应成功
	 */
	public EntityResult<T> responseSuccess(T data) {
		super.responseSuccess();
		this.setData(data);
		return this;
	}

	/**
	 * 响应失败
	 */
	@Override
	public EntityResult<T> responseFail(ResponseCodeEnum responseCodeEnum) {
		super.responseFail(responseCodeEnum);
		return this;
	}

	/**
	 * 响应失败
	 */
	@Override
	public EntityResult<T> responseFail(ResponseCodeEnum responseCodeEnum, String message) {
		super.responseFail(responseCodeEnum, message);
		return this;
	}

}
